package edu.sjb.map.prizes;

import edu.sjb.Drawable;
import edu.sjb.characters.GameCharacter;
import edu.sjb.constants.ImageConstants;
import edu.sjb.constants.ScoreConstants;
import edu.sjb.threads.SoundThread;

public class NuclearBomb extends PowerUp {
	public NuclearBomb() {
		super();
	}

	@Override
	public void grab() {

		SoundThread.startSFXNuclearBomb();
		game().changeScore(ScoreConstants.NUCLEAR_BOMB);
		GameCharacter threatened = null;
		for (int i = 0; i < game().getCharacters().size(); i++) {
			threatened = game().getCharacters().get(i);
			if ((threatened.posX() > posX() - game().mario().posX())
			        && (threatened.posX() < posX() + 800
			                - game().mario().posX())) {
				if (threatened != game().mario()) {
					threatened.die();
				}
			}
		}
	}

	@Override
	public void run() {
	}

	protected Object clone() {
		NuclearBomb nucBomb = new NuclearBomb();
		Drawable img = new Drawable(ImageConstants.NUCLEAR_BOMB, true);
		nucBomb.setImage(img);
		return nucBomb;
	}

}
